package com.coship.vasms.adstorm.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import com.coship.vasms.adstorm.dao.ADArrangeDao;
import com.coship.vasms.adstorm.model.ADArrange;

public class ADArrangeDaoImpl implements ADArrangeDao {
	
    private SqlMapClientTemplate sqlMapClientTemplate;
	
	public SqlMapClientTemplate getSqlMapClientTemplate() {
		return sqlMapClientTemplate;
	}

	public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) {
		this.sqlMapClientTemplate = sqlMapClientTemplate;
	}
	
	@Override
	public void save(ADArrange adarrange) {
		sqlMapClientTemplate.insert("insertArrange", adarrange);
	}

	@Override
	public void update(ADArrange adarrange) {
		sqlMapClientTemplate.update("updateArrange", adarrange);
	}

	@Override
	public void delete(Integer id) {
		sqlMapClientTemplate.delete("deleteArrange", id);
	}

	@Override
	public ADArrange findById(Integer id) {
		return (ADArrange)sqlMapClientTemplate.queryForObject("getArrangeById", id);
	}

	@Override
	public ADArrange queryByPositionBasicCodeAndTime(String positionBasicCode,
			String time) {
		Map<String, String> param = new HashMap<String, String>();
		param.put("positionInfoCode", positionBasicCode);
		param.put("systemTime", time);
		return (ADArrange)sqlMapClientTemplate.queryForObject("getArrangeByPositionBasicCodeAndTime", param);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ADArrange> queryAll() {
		return sqlMapClientTemplate.queryForList("getAllArrange");
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ADArrange> queryByAdvertiseId(Integer advertiseId) {
		return sqlMapClientTemplate.queryForList("getArrangeByAdvertiseId", advertiseId);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ADArrange> queryByPositionBasicCode(String positionBasicCode) {
		return sqlMapClientTemplate.queryForList("getAllArrangeByPositionBasicCode", positionBasicCode);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ADArrange> queryByPositionInfoCode(String positionInfoCode) {
		return sqlMapClientTemplate.queryForList("getAllArrangeByPositionInfoCode", positionInfoCode);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ADArrange> queryByTime(String time) {
		return sqlMapClientTemplate.queryForList("getOndateArrangeByTime", time);
	}

	@Override
	public int updateArrangeByBasicCode(ADArrange adarrange) {
		// TODO Auto-generated method stub
		return sqlMapClientTemplate.update("updateArrangeByBasicCode", adarrange);
	}

	

}
